
from util.selenium.webdriver.common.by import By

from base.BaseMethod import BM
from util.DataQuery.FormDataDecorator import FormDataDecorator

class WriteHRInfo():
    ent_total_loc = (By.CSS_SELECTOR, 'input#entHrTotal')
    ent_onjob_loc = (By.CSS_SELECTOR, 'input#entHrOnJob')
    ent_part_loc = (By.CSS_SELECTOR, 'input#entHrPart')
    ent_ext_loc = (By.CSS_SELECTOR, 'input#entHrExt')
    ent_forg_loc = (By.CSS_SELECTOR, 'input#entHrForg')
    ent_abroed_loc = (By.CSS_SELECTOR, 'input#entHrAbroed')
    ent_tsdplan_loc = (By.CSS_SELECTOR, 'input#entHrTsdplan')

    sat_total_loc = (By.CSS_SELECTOR, 'input#satHrTotal')
    sat_onjob_loc = (By.CSS_SELECTOR, 'input#satHrOnJob')
    sat_part_loc = (By.CSS_SELECTOR, 'input#satHrPart')
    sat_ext_loc = (By.CSS_SELECTOR, 'input#satHrExt')
    sat_forg_loc = (By.CSS_SELECTOR, 'input#satHrForg')
    sat_abroed_loc = (By.CSS_SELECTOR, 'input#satHrAbroed')
    sat_tsdplan_loc = (By.CSS_SELECTOR, 'input#satHrTsdplan')
    # 写代码时方便提示, 基本方法完成后删除
    # driver = driver
    def __init__(self, driver=None):
        self.driver = driver
    @property
    def class_name(self):
        return self.__class__.__name__

    def input_ent_info(self, total=None, onjob=None, parttime=None, tempstaff=None, foreigner=None, returnees=None, thstalents=None):
        BM.input(driver=self.driver, ele_loc=self.ent_total_loc, keys=total)
        BM.input(driver=self.driver, ele_loc=self.ent_onjob_loc, keys=onjob)
        BM.input(driver=self.driver, ele_loc=self.ent_part_loc, keys=parttime)
        BM.input(driver=self.driver, ele_loc=self.ent_ext_loc, keys=tempstaff)
        BM.input(driver=self.driver, ele_loc=self.ent_forg_loc, keys=foreigner)
        BM.input(driver=self.driver, ele_loc=self.ent_abroed_loc, keys=returnees)
        BM.input(driver=self.driver, ele_loc=self.ent_tsdplan_loc, keys=thstalents)

    def input_sat_info(self, total=None, onjob=None, parttime=None, tempstaff=None, foreigner=None, returnees=None, thstalents=None):
        BM.input(driver=self.driver, ele_loc=self.sat_total_loc, keys=total)
        BM.input(driver=self.driver, ele_loc=self.sat_onjob_loc, keys=onjob)
        BM.input(driver=self.driver, ele_loc=self.sat_part_loc, keys=parttime)
        BM.input(driver=self.driver, ele_loc=self.sat_ext_loc, keys=tempstaff)
        BM.input(driver=self.driver, ele_loc=self.sat_forg_loc, keys=foreigner)
        BM.input(driver=self.driver, ele_loc=self.sat_abroed_loc, keys=returnees)
        BM.input(driver=self.driver, ele_loc=self.sat_tsdplan_loc, keys=thstalents)

    @FormDataDecorator
    def write_hr_info(self,type=None, total=None, onjob=None, parttime=None, tempstaff=None, foreigner=None, returnees=None, thstalents=None):
        # # # # # # # # # # # #  等从数据库中读取数据时再加判断。
        # total = onjob + parttime + tempstaff + foreigner + returnees + thstalents
        if type == 1:
            return {"dataEntHumanres.entHrTotal": str(total), "dataEntHumanres.entHrOnjob": str(onjob),
                    "dataEntHumanres.entHrPart": str(parttime), "dataEntHumanres.entHrExt": str(tempstaff),
                    "dataEntHumanres.entHrForg": str(foreigner), "dataEntHumanres.entHrAbroed": str(returnees),
                    "dataEntHumanres.entHrTsdplan": str(thstalents)}
            # self.input_ent_info(total=total, onjob=onjob, parttime=parttime, tempstaff=tempstaff, foreigner=foreigner, returnees=returnees, thstalents=thstalents)
        else:
            return {"dataEntHumanres.satHrTotal": str(total), "dataEntHumanres.satHrOnjob": str(onjob),
                    "dataEntHumanres.satHrPart": str(parttime), "dataEntHumanres.satHrExt": str(tempstaff),
                    "dataEntHumanres.satHrForg": str(foreigner), "dataEntHumanres.satHrAbroed": str(returnees),
                    "dataEntHumanres.satHrTsdplan": str(thstalents)}
            # self.input_sat_info(total=total, onjob=onjob, parttime=parttime, tempstaff=tempstaff, foreigner=foreigner, returnees=returnees, thstalents=thstalents)
